/*
 * @Author: Leo.wang wanglizhigs@163.com
 * @Date: 2023-11-29 09:29:27
 * @LastEditors: Leo.wang wanglizhigs@163.com
 * @LastEditTime: 2023-11-29 10:37:53
 * @FilePath: /tuberculosis_screening_app/src/service/storage.service.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE, 
 */
const local = {
  set: (key: string, value: unknown) => {
    localStorage && localStorage.setItem(key, JSON.stringify(value));
  },
  get: (key: string): unknown => {
    if (localStorage) {
      const result = localStorage.getItem(key);
      return result ? JSON.parse(result) : undefined;
    } else {
      return;
    }
  },
  remove: (key: string) => {
    localStorage && localStorage.removeItem(key);
  },
  clear: () => {
    localStorage && localStorage.clear();
  },
};
const session = {
  set: (key: string, value: unknown) => {
    sessionStorage && sessionStorage.setItem(key, JSON.stringify(value));
  },
  get: (key: string): unknown => {
    if (sessionStorage) {
      const result = sessionStorage.getItem(key);
      return result ? JSON.parse(result) : undefined;
    } else {
      return;
    }
  },
  remove: (key: string) => {
    sessionStorage && sessionStorage.removeItem(key);
  },
  clear: () => {
    sessionStorage && sessionStorage.clear();
  },
};

const STORAGE_KEY = {}

export { local, session, STORAGE_KEY };
